import { BaseServices } from "./base.services";
import { APIUrl, APIMethod, RespInfo } from "./request.services";


export class CommonService extends BaseServices {
  private static _ins: CommonService = new CommonService();
  public static get ins(): CommonService {
    return this._ins ? this._ins : this._ins = new CommonService();
  }

  /** 校验链接可访问性 */
  public regHref(href: string): Promise<boolean> {
    const url = APIUrl.Common + APIMethod.RegHref;
    const data = { href };
    return new Promise<boolean>((reslove, reject) => {
      this.request(url, data).then(async (res: RespInfo<void>) => {
        reslove(true);
      }).catch(err => {
        reslove(false)
      })
    });
  }

}

export const commonService: CommonService = CommonService.ins;